﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VntNet.PowerSchemeSwitcher
{
    class PowerSettingChangeNotification
    {
        internal event Action PowerSettingsChanged;
        RegistryChangesNotificationHelper _regNotHelper;

        public PowerSettingChangeNotification()
        {
            //register for changes in
            //HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes
            _regNotHelper = new RegistryChangesNotificationHelper(RegistryChangesNotificationHelper.HKeyEnum.LocalMachine, @"SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes", true);
            _regNotHelper.RegistryChanged += new Action(_regNotHelper_RegistryChanged);
        }

        void _regNotHelper_RegistryChanged()
        {
            OnPowerSettingsChanged();
        }

        void OnPowerSettingsChanged()
        {
            if (PowerSettingsChanged != null)
                PowerSettingsChanged();
        }
                    
    }
}
